#pragma once

#include "StringConverter.h"

using namespace std;

class FileNameTokenizer
{
public:

   FileNameTokenizer(const string& fullFilePath)
   {
      char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT];
      errno_t err;

      err = _splitpath_s(fullFilePath.c_str(), drive, _MAX_DRIVE, dir, _MAX_DIR, fname, _MAX_FNAME, ext, _MAX_EXT);

      if (0 == err)
      {
         Drive = drive;
         DriveW = NarrowToWide(Drive);

         Directory = dir;
         DirectoryW = NarrowToWide(Directory);

         Name = fname;
         NameW = NarrowToWide(Name);

         Extension = ext;
         ExtensionW = NarrowToWide(Extension);
      }
   }

   FileNameTokenizer(const wstring& fullFilePath)
   {
      wchar_t drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT];
      errno_t err;

      err = _wsplitpath_s(fullFilePath.c_str(), drive, _MAX_DRIVE, dir, _MAX_DIR, fname, _MAX_FNAME, ext, _MAX_EXT);

      if (0 == err)
      {
         DriveW = drive;         
         Drive = WideToNarrow(DriveW);

         DirectoryW = dir;
         Directory = WideToNarrow(DirectoryW);

         NameW = fname;
         Name = WideToNarrow(NameW);

         ExtensionW = ext;
         Extension = WideToNarrow(ExtensionW);
      }
   }

   ~FileNameTokenizer()
   {
   }

   string Drive;
   string Directory;
   string Name;
   string Extension;

   wstring DriveW;
   wstring DirectoryW;
   wstring NameW;
   wstring ExtensionW;
};
